package org.study.mybatis.boot.controller;

import com.alibaba.fastjson2.JSON;
import jakarta.validation.Valid;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;
import org.study.mybatis.boot.vo.TestVO;

/**
 * 类的描述
 *
 * @author Administrator
 * @date 2021-05-26
 */
@Slf4j
@RestController
@RequestMapping("/test")
public class TestController {
    @RequestMapping("/check")
    public String query(@ModelAttribute @Valid TestVO testVO, BindingResult result) {
        log.info("请求参数：{}", JSON.toJSONString(testVO));
        if (result.hasErrors()) {
            return "error";
        }
        return JSON.toJSONString(testVO);
    }
}
